import React, { Component } from 'react';
import ReactEchartsCore from 'echarts-for-react/lib/core';
import 'echarts/lib/chart/pie';
import 'echarts/lib/component/tooltip';
import 'echarts/lib/component/title';

export default class PieCharts extends Component{
    constructor(props){
        super(props);
        this.state={
            dataSource:props.dataSource,
        }
    }

    componentWillReceiveProps(nextProps){
        if(nextProps.dataSource){
            this.setState(
                {
                    dataSource:nextProps.dataSource,
                }
            )
        }
    }

    // 渲染
    render(){
        return(
            <ReactEchartsCore 
            echarts={echarts}
            notMerge={true}
            lazyUpdate={true}
            option={option}
            style={{ width: '100%' }}
            theme="light"
            />  
        )
    }
}